package com.hemaapp.yjnh.nettask;

import java.net.URL;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;

import com.hemaapp.yjnh.R;

import xtom.frame.image.load.XtomImageTask;
import xtom.frame.util.XtomImageUtil;

/**加载网络头像的任务
 * @author GuiyouZhang
 * Date：2016年1月4日 下午4:56:36
 * Email:guiyouzhang@163.com
 */
public class ImageAvatarTask extends XtomImageTask {
	
	private ImageView imageView;
	
	public ImageAvatarTask(ImageView imageView, String path, Object context, Size size) {
		super(imageView, path, context, size);
		this.imageView = imageView;
	}
	
	public ImageAvatarTask(ImageView imageView, URL url, Object context, Size size) {
		super(imageView, url, context, size);
		this.imageView = imageView;
	}
	
	public ImageAvatarTask(ImageView imageView, URL url, Object context, View fatherView, Size size) {
		super(imageView, url, context, fatherView, size);
		this.imageView = imageView;
	}

	@Override
	public void setBitmap(Bitmap bitmap) {
		bitmap = XtomImageUtil.getRoundedCornerBitmap(bitmap, 500);
		super.setBitmap(bitmap);
	}
	
	@Override
	public void failed() {
		super.failed();
		imageView.setImageResource(R.drawable.default_rabbit_grey);
	}

	@Override
	public void beforeload() {
		super.beforeload();
		imageView.setImageResource(R.drawable.default_rabbit_grey);
	}
}
